Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
Short hand for jquery selector ":checked" applied on a list

I have a list of jquery radio buttons :

<input type="radio" class="editorInput" name="radioEditor" value="1" id="radio_1">
<input type="radio" class="editorInput" name="radioEditor" value="2" id="radio_2">
<input type="radio" class="editorInput" name="radioEditor" value="3" id="radio_3">
<input type="radio" class="editorInput" name="radioEditor" value="4" id="radio_4">

I need to find the one that is checked, and get its value (or text).

For value I know I can do :

var val = $(".editorInput:checked").val();

But in some other cases, in my script I have an already build list containing these controls, for example selected by

var list = $(".editorInput");

The only way I know to get the checked one in this list requires to write an each iterator :

$(list).each(function ()
{
    if ($(this).is(":checked"))
    {
        val = $(this).val();
    }
});

My question is : is there a shorter jquery syntax to get the "checked" radio button from a list of controls (like above) containing several controls, in a single line ?

Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can modify jQuery objects, for example one way to do it is [filter() Method][1]

Another honorably mentions should go to find() Method

$list.filter(':checked') filters out checked elements.

$ulList.find('li') finds all <li> elements inside the list.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda